#include <linux/irq.h>
#include <linux/interrupt.h>
#include <linux/init.h> /* Needed for the macros */
#include <linux/kernel.h> /* Needed for pr_info() */
#include <linux/module.h> /* Needed by all modules */
#include <linux/platform_device.h>
#include <linux/input.h>
#include <linux/timer.h>
#include <linux/bug.h>
#include <linux/i2c.h>
#include <linux/slab.h>

#define  TRUE(condition)  BUG_ON(!(condition))

/**
 *
 *
 my_platform_device003 {
 status = "okay";
 compatible ="my_platform_device_003";
 interrupt-parent = <&gpio1>;
 interrupts = <7 2>;
 };


 https://stackoverflow.com/questions/12256986/what-is-the-difference-between-devm-kzalloc-and-kzalloc-in-linux-driver-prog

 */

struct data {
	char name[48];
	int timeout;
};

int myprobe(struct platform_device *pdev) {
	struct data *priv;
	char *tmp="wsxedc";
	priv = devm_kzalloc(&pdev->dev, sizeof(*priv),
	GFP_KERNEL);
	memcpy(priv->name,tmp,strlen(tmp));
	priv->timeout = 14000 ;
//	strlcpy(priv->name, "Au1xxx PSC I2C 147258", sizeof(priv->name));
	pr_info("myplatformdriver myprobe  start \n");
	platform_set_drvdata(pdev, priv);
	pr_info("myplatformdriver myprobe end  \n");
	return 0;
}

int myremove(struct platform_device *pdev) {
	struct data *a = platform_get_drvdata(pdev);
	pr_info("myplatformdriver myremove  start  \n");
	pr_info("a->name = %s\n", a->name);
	pr_info("a->timeout = %d\n", a->timeout);
	pr_info("myplatformdriver myremove  end \n");
	return 0;
}

int mysuspend(struct device *pdev, pm_message_t state) {
	pr_err("myplatformdriver mysuspend \n");
	return 0;
}

int myresume(struct device *pdev) {
	pr_info("myplatformdriver myresume \n");
	return 0;
}

struct of_device_id my_of_match_table =
		{ .compatible = "my_platform_device_003", };

struct platform_driver my_platform_driver = { .driver = { .of_match_table =
		&my_of_match_table, .name = "my-platform-driver", .owner = THIS_MODULE,
		.suspend = mysuspend, .resume = myresume, }, .probe = myprobe, .remove =
		myremove, };

module_platform_driver(my_platform_driver);

MODULE_LICENSE("GPL");
MODULE_AUTHOR("Andy");
MODULE_DESCRIPTION("andy one-key driver");
MODULE_ALIAS("one-key");
